﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;


namespace TestDxfDocument
{
    class Other309
    {
        //外切槽和切断车刀
        public static void TurningToolForODGroovingAndParting(Dictionary<string, Object> data) {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //1,轮廓层
            Layer dimensioning = new Layer("dimensioning");    //2,尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //3,基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //4,中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            string path = "D:\\PPPPPPPPPPPPPPPPP\\dxf\\Other309\\TurningToolForODGroovingAndParting.dxf";//Convert.ToString(data["path"]);
            double pi = Math.PI;
            //参数名取自ISO13399-309_8.1
            double h = 12;
            double b = 12;
            double lf = 120;
            double lh = 21;
            double cdx = 10;
            double ecd = 2.5;
            double eca = 30;
            double wf = 11;
            double cw = 4;
            double karp = 90;
            try
            {
                path = Convert.ToString(data["path"]);
            }
            catch (Exception) { }
            try
            {
                h = Convert.ToDouble(data["h"]);
            }
            catch (Exception) { }
            try
            {
                b = Convert.ToDouble(data["b"]);
            }
            catch (Exception) { }
            try
            {
                lf = Convert.ToDouble(data["lf"]);
            }
            catch (Exception) { }
            try
            {
                lh = Convert.ToDouble(data["lh"]);
            }
            catch (Exception) { }
            try
            {
                cdx = Convert.ToDouble(data["cdx"]);
            }
            catch (Exception) { }
            try
            {
                ecd = Convert.ToDouble(data["ecd"]);
            }
            catch (Exception) { }
            try
            {
                eca = Convert.ToDouble(data["eca"]);
            }
            catch (Exception) { }
            try
            {
                wf = Convert.ToDouble(data["wf"]);
            }
            catch (Exception) { }
            try
            {
                cw = Convert.ToDouble(data["cw"]);
            }
            catch (Exception) { }
            try
            {
                karp = Convert.ToDouble(data["karp"]);
            }
            catch (Exception) { }

            Vector2 c1 = new Vector2(0, 0);
            Vector2 c2 = new Vector2(c1.X - b, c1.Y);
            Vector2 c3 = new Vector2(c2.X,c2.Y-h/2);
            Vector2 c4 = new Vector2(c3.X,c3.Y-h);
            Vector2 c5 = new Vector2(c4.X,c4.Y-h);
            Vector2 c6 = new Vector2(c1.X,c5.Y);
            Vector2 c7= new Vector2(c6.X,c4.Y);
            Vector2 c8 = new Vector2(c7.X,c3.Y);

            Vector2 c9 = new Vector2(c6.X,c6.Y-2);
            Vector2 c10 = new Vector2(c5.X,c5.Y-2);
            Vector2 c11 = new Vector2(c10.X,c10.Y-h);
            Vector2 c16 = new Vector2(c9.X,c9.Y-h);
            Vector2 i1 = new Vector2(c11.X + wf + cw / 2, c11.Y - lh);
            Vector2 i2 = new Vector2(c9.X, i1.Y + cdx - 2);
            Vector2 i3 = new Vector2(i2.X - (cw - 1), i2.Y);
            Vector2 i4 = new Vector2(i1.X - cw, i1.Y);
            Vector2 c15 = new Vector2(i2.X, i1.Y + cdx);
            Vector2 c14 = new Vector2(i3.X, c15.Y);
            Vector2 c13 = new Vector2(c11.X + ecd, c14.Y);
            Vector2 c12 = fun.Inters(c10, c11, c13, fun.Polar(c13, pi / 2 + eca * pi / 180, 1));

            //上部
            LwPolyline upper = Pus.AddPointsToLwPolyLine(c6, c1, c2, c5);
            fun.PolyFill(dxf, upper, 0.1, contour);
            Line line1 = new Line(c3, c8);
            line1.Linetype = Linetype.DashDot;
            Line line2 = new Line(c4, c7);
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            dxf.AddEntity(line2);
            Spline spline1 = Pus.TwoPointsWaveline(c5,c6,10,0.5);
            dxf.AddEntity(spline1);
            //填充
            LwPolyline hatchLine = Pus.AddPointsToLwPolyLine(c8, c3, c4, c7);
            hatchLine.IsClosed = true;
            Pus.HatchThePolyline(dxf, hatchLine);
            //
            LwPolyline lower = Pus.AddPointsToLwPolyLine(c10, c12, c13, c15, c9);
            fun.PolyFill(dxf, lower, 0.1, contour);
            Spline spline2 = Pus.TwoPointsWaveline(c10, c9, 10, 0.5);
            dxf.AddEntity(spline2);
            //insert
            Solid insert1 = new Solid(i1, i2, i3);
            insert1.Color = AciColor.Red;
            dxf.AddEntity(insert1);
            Solid insert2 = new Solid(i1, i3, i4);
            insert2.Color = AciColor.Red;
            dxf.AddEntity(insert2);
            Pus.DrawPlineByTwoPoints(dxf, c11, c16);
            Pus.DrawPlineByTwoPoints(dxf, c14, i3);
            Pus.DrawPlineByTwoPoints(dxf, c15, i2);
            //标注
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;
            LinearDimension dim_lf = new LinearDimension(new Line(c1, i1), offset, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_lf, lf);
            LinearDimension dim_b = new LinearDimension(new Line(c1, c2), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, dim_b, b);
            LinearDimension dim_h = new LinearDimension(new Line(c3, c4), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, dim_h, h);
            LinearDimension dim_lh = new LinearDimension(new Line(c11, i4), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, dim_lh, lh);
            LinearDimension dim_cdx = new LinearDimension(new Line(i4,c13), offset*2, 90, dimensionStyle);
            fun.dxflinedim(dxf, dim_cdx, cdx);
            LinearDimension dim_ecd = new LinearDimension(new Line(c12, c13), offset, -180, dimensionStyle);
            fun.dxflinedim(dxf, dim_ecd, ecd);
            LinearDimension dim_wf = new LinearDimension(new Line(c12, new Vector2((i3.X+i2.X)/2,i4.Y)), offset *2.5, 180, dimensionStyle);
            fun.dxflinedim(dxf, dim_wf, wf);
            LinearDimension dim_cw = new LinearDimension(new Line(i4, i1), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, dim_cw, cw);
            Angular2LineDimension dim_eca = new Angular2LineDimension(new Line(c12, fun.Polar(c12, -pi / 2, 1)), new Line(c12, c13),offset, dimensionStyle);
            dim_eca.UserText = eca + "°";
            dim_eca.SetDimensionLinePosition(fun.Polar(c12, -70 * pi / 180, offset * 1.6));
            dxf.AddEntity(dim_eca);
            Angular2LineDimension dim_karp = new Angular2LineDimension(new Line(i4, i1), new Line(i4, fun.Polar(i4, -pi / 2, 1)), offset, dimensionStyle);
            dim_karp.UserText = karp + "°";
            dim_karp.SetDimensionLinePosition(fun.Polar(i4, -pi / 4, offset * 2));
            dxf.AddEntity(dim_karp);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        //内镗刀
        public static void BoringBarForIDGrooving(Dictionary<string, Object> data) {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //1,轮廓层
            Layer dimensioning = new Layer("dimensioning");    //2,尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //3,基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //4,中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            string path = "D:\\PPPPPPPPPPPPPPPPP\\dxf\\Other309\\BoringBarForIDGrooving.dxf";//Convert.ToString(data["path"]);
            double pi = Math.PI;
            //参数名取自ISO13399-309_9.1
            double dcon = 12;
            double lf = 120;
            double lh = 11;
            double cdx = 10;
            double ecd = 3;
            double eca = 30;
            double wf = 11;
            double cw = 4;
            double karp = 90;
            try
            {
                path = Convert.ToString(data["path"]);
            }
            catch (Exception) { }
            try
            {
                dcon = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception) { }
            try
            {
                lf = Convert.ToDouble(data["lf"]);
            }
            catch (Exception) { }
            try
            {
                lh = Convert.ToDouble(data["lh"]);
            }
            catch (Exception) { }
            try
            {
                cdx = Convert.ToDouble(data["cdx"]);
            }
            catch (Exception) { }
            try
            {
                ecd = Convert.ToDouble(data["ecd"]);
            }
            catch (Exception) { }
            try
            {
                eca = Convert.ToDouble(data["eca"]);
            }
            catch (Exception) { }
            try
            {
                wf = Convert.ToDouble(data["wf"]);
            }
            catch (Exception) { }
            try
            {
                cw = Convert.ToDouble(data["cw"]);
            }
            catch (Exception) { }
            try
            {
                karp = Convert.ToDouble(data["karp"]);
            }
            catch (Exception) { }
            Vector2 c1 = new Vector2(0, 0);
            Vector2 c2 = new Vector2(c1.X - dcon, c1.Y);
            Vector2 c3 = new Vector2(c2.X, c2.Y - dcon);
            Vector2 c4 = new Vector2(c3.X, c3.Y - dcon);
            Vector2 c5 = new Vector2(c1.X, c4.Y);
            Vector2 c6 = new Vector2(c5.X, c3.Y);
            LwPolyline upper = Pus.AddPointsToLwPolyLine(c5, c1, c2, c4);
            fun.PolyFill(dxf, upper, 0.1, contour);
            //波浪线
            dxf.AddEntity(Pus.TwoPointsWaveline(c4, c5, 12, 0.5));
            Circle circle = new Circle(new Vector2((c3.X + c6.X) / 2,c1.Y-dcon), dcon / 2);
            circle.Linetype = Linetype.DashDot;
            dxf.AddEntity(circle);
            //填充圆
            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>();
            HatchBoundaryPath cirpath = new HatchBoundaryPath(new List<EntityObject>{ circle });
            boundary.Add(cirpath);
            Hatch hatch = new Hatch(HatchPattern.Line, boundary, true);
            hatch.Pattern.Angle = 45;
            hatch.Pattern.Scale = 8;
            dxf.AddEntity(hatch);

            //下部
            Vector2 c7 = new Vector2(c4.X, c4.Y - 3);
            Vector2 c13 = new Vector2(c5.X, c5.Y - 3);
            //波浪线
            dxf.AddEntity(Pus.TwoPointsWaveline(c7,c13,12,0.5));
            Vector2 c8 = new Vector2(c7.X, c7.Y - 5);
            Vector2 c12 = new Vector2(c13.X, c8.Y);
            Pus.DrawPlineByTwoPoints(dxf, c8, c12);
            //中心线点
            Vector2 cen1 = new Vector2((c1.X + c2.X) / 2, c1.Y);
            Vector2 i1 = new Vector2(cen1.X+wf,c8.Y-lh);
            Vector2 i2 = new Vector2(i1.X, i1.Y + cw);
            Vector2 i3 = new Vector2(c12.X - 1, i2.Y - 1);
            Vector2 i4 = new Vector2(i3.X, i1.Y + 1);
            Vector2 cen2 = new Vector2(cen1.X, i4.Y);
            fun.drawPlinetype(dxf, new Vector2[] { new Vector2(cen1.X,cen1.Y+1), new Vector2(cen2.X,cen2.Y-1) }, 0.15, centre, Linetype.Center);
            Vector2 c10 = new Vector2(c8.X + ecd, i4.Y);
            Vector2 c9 = fun.Inters(c7, c8, c10, fun.Polar(c10, pi / 2 + eca * pi / 180, 1));
            Vector2 c11 = fun.Inters(i2, i3, c12, c13);
            LwPolyline lower = Pus.AddPointsToLwPolyLine(c7, c9, c10, i4, i3, c11, c13);
            fun.PolyFill(dxf, lower, 0.1, contour);
            //insert
            Solid insert1 = new Solid(i2, i3, i4);
            insert1.Color = AciColor.Red;
            Solid insert2 = new Solid(i1, i2, i4);
            insert2.Color = AciColor.Red;
            dxf.AddEntity(insert1);
            dxf.AddEntity(insert2);
            //标注
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;
            LinearDimension dim_lf = new LinearDimension(new Line(c1, i2), offset + i1.X - (c1.X+i2.X)/2, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_lf, lf);
            LinearDimension dim_dcon = new LinearDimension(new Line(c1, c2), offset, 0, dimensionStyle);
            dim_dcon.UserText = "φ" + dcon;
            fun.dxflinedim(dxf, dim_dcon, dcon);
            LinearDimension dim_oal = new LinearDimension(new Line(c1, i1), offset * 2, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_oal, lf + cw);
            LinearDimension dim_lh = new LinearDimension(new Line(c8, i1), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, dim_lh, lh);
            LinearDimension dim_ecd = new LinearDimension(new Line(c9, c10), offset + 5
, -180, dimensionStyle);
            fun.dxflinedim(dxf, dim_ecd, ecd);
            LinearDimension dim_wf = new LinearDimension(new Line(cen2, i1), offset * 2.5, 180, dimensionStyle);
            fun.dxflinedim(dxf, dim_wf, wf);
            LinearDimension dim_cw = new LinearDimension(new Line(i2, i1), offset, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_cw, cw);
            Angular2LineDimension dim_eca = new Angular2LineDimension(new Line(c9, fun.Polar(c9, -pi / 2, 1)), new Line(c9, c10), offset * 3, dimensionStyle);
            dim_eca.UserText = eca + "°";
            dxf.AddEntity(dim_eca);
            Angular2LineDimension dim_karp = new Angular2LineDimension(new Line(i1, fun.Polar(i1,0,1)), new Line(i1, fun.Polar(i1, -pi / 2, 1)), offset * 2, dimensionStyle);
            dim_karp.UserText = karp + "°";
            dxf.AddEntity(dim_karp);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        //背镗杆
        public static void PullBackBoringBar(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //1,轮廓层
            Layer dimensioning = new Layer("dimensioning");    //2,尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //3,基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //4,中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            string path = "D:\\PPPPPPPPPPPPPPPPP\\dxf\\Other309\\PullBackBoringBar.dxf";//Convert.ToString(data["path"]);
            double pi = Math.PI;
            //参数名取自ISO13399-309_9.1
            double epsr = 55;
            double dcon = 12;
            double lf = 120;
            double lh = 12;
            double ldred = 18;
            double ecd = 3;
            double eca = 30;
            double wf = 11;
            double cw = 4;
            double karp = 90;
            try
            {
                path = Convert.ToString(data["path"]);
            }
            catch (Exception) { }
            try
            {
                epsr = Convert.ToDouble(data["epsr"]);
            }
            catch (Exception) { }
            try
            {
                dcon = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception) { }
            try
            {
                lf = Convert.ToDouble(data["lf"]);
            }
            catch (Exception) { }
            try
            {
                lh = Convert.ToDouble(data["lh"]);
            }
            catch (Exception) { }
            try
            {
                ldred = Convert.ToDouble(data["ldred"]);
            }
            catch (Exception) { }
            try
            {
                ecd = Convert.ToDouble(data["ecd"]);
            }
            catch (Exception) { }
            try
            {
                eca = Convert.ToDouble(data["eca"]);
            }
            catch (Exception) { }
            try
            {
                wf = Convert.ToDouble(data["wf"]);
            }
            catch (Exception) { }
            try
            {
                cw = Convert.ToDouble(data["cw"]);
            }
            catch (Exception) { }
            try
            {
                karp = Convert.ToDouble(data["karp"]);
            }
            catch (Exception) { }
            Vector2 c1 = new Vector2(0, 0);
            Vector2 c2 = new Vector2(c1.X - dcon, c1.Y);
            Vector2 c3 = new Vector2(c2.X, c2.Y - dcon);
            Vector2 c4 = new Vector2(c3.X, c3.Y - dcon);
            Vector2 c5 = new Vector2(c1.X, c4.Y);
            Vector2 c6 = new Vector2(c5.X, c3.Y);
            LwPolyline upper = Pus.AddPointsToLwPolyLine(c5, c1, c2, c4);
            fun.PolyFill(dxf, upper, 0.1, contour);
            //波浪线
            dxf.AddEntity(Pus.TwoPointsWaveline(c4, c5, 12, 0.5));
            Circle circle = new Circle(new Vector2((c3.X + c6.X) / 2, c1.Y - dcon), dcon / 2);
            circle.Linetype = Linetype.DashDot;
            dxf.AddEntity(circle);
            //填充圆
            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>();
            HatchBoundaryPath cirpath = new HatchBoundaryPath(new List<EntityObject> { circle });
            boundary.Add(cirpath);
            Hatch hatch = new Hatch(HatchPattern.Line, boundary, true);
            hatch.Pattern.Angle = 45;
            hatch.Pattern.Scale = 8;
            dxf.AddEntity(hatch);

            //下部
            Vector2 c7 = new Vector2(c4.X, c4.Y - 3);
            Vector2 c13 = new Vector2(c5.X, c5.Y - 3);
            //波浪线
            dxf.AddEntity(Pus.TwoPointsWaveline(c7, c13, 12, 0.5));
            Vector2 c8 = new Vector2(c7.X, c7.Y - 5);
            Vector2 c12 = new Vector2(c13.X, c8.Y);
            Pus.DrawPlineByTwoPoints(dxf, c8, c12);
            //中心线点
            Vector2 cen1 = new Vector2((c1.X + c2.X) / 2, c1.Y);
            Vector2 i1 = new Vector2(cen1.X + wf, c8.Y - lh);
            Vector2 i2 = new Vector2(i1.X, i1.Y + cw);
            Vector2 i3 = new Vector2(c12.X - 1, i2.Y - 1);
            Vector2 i4 = new Vector2(i3.X, i1.Y + 1);
            Vector2 cen2 = new Vector2(cen1.X, i4.Y);
            fun.drawPlinetype(dxf, new Vector2[] { new Vector2(cen1.X, cen1.Y + 1), new Vector2(cen2.X, cen2.Y - 1) }, 0.15, centre, Linetype.Center);
            Vector2 c10 = new Vector2(c8.X + ecd, i4.Y);
            Vector2 c9 = fun.Inters(c7, c8, c10, fun.Polar(c10, pi / 2 + eca * pi / 180, 1));
            Vector2 c11 = fun.Inters(i2, i3, c12, c13);
            LwPolyline lower = Pus.AddPointsToLwPolyLine(c7, c9, c10, i4, i3, c11, c13);
            fun.PolyFill(dxf, lower, 0.1, contour);
            //insert
            Solid insert1 = new Solid(i2, i3, i4);
            insert1.Color = AciColor.Red;
            Solid insert2 = new Solid(i1, i2, i4);
            insert2.Color = AciColor.Red;
            dxf.AddEntity(insert1);
            dxf.AddEntity(insert2);
            //标注
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;
            LinearDimension dim_lf = new LinearDimension(new Line(c1, i2), offset + i1.X - (c1.X + i2.X) / 2, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_lf, lf);
            LinearDimension dim_dcon = new LinearDimension(new Line(c1, c2), offset, 0, dimensionStyle);
            dim_dcon.UserText = "φ" + dcon;
            fun.dxflinedim(dxf, dim_dcon, dcon);
            LinearDimension dim_oal = new LinearDimension(new Line(c1, i1), offset * 2, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_oal, lf + cw);
            LinearDimension dim_lh = new LinearDimension(new Line(c8, i1), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, dim_lh, lh);
            LinearDimension dim_ecd = new LinearDimension(new Line(c9, c10), offset + 5, -180, dimensionStyle);
            fun.dxflinedim(dxf, dim_ecd, ecd);
            LinearDimension dim_wf = new LinearDimension(new Line(cen2, i1), offset * 2.5, 180, dimensionStyle);
            fun.dxflinedim(dxf, dim_wf, wf);
            LinearDimension dim_cw = new LinearDimension(new Line(i2, i1), offset, -90, dimensionStyle);
            fun.dxflinedim(dxf, dim_cw, cw);
            Angular2LineDimension dim_eca = new Angular2LineDimension(new Line(c9, fun.Polar(c9, -pi / 2, 1)), new Line(c9, c10), offset * 3, dimensionStyle);
            dim_eca.UserText = eca + "°";
            dxf.AddEntity(dim_eca);
            Angular2LineDimension dim_karp = new Angular2LineDimension(new Line(i1, fun.Polar(i1, 0, 1)), new Line(i1, fun.Polar(i1, -pi / 2, 1)), offset * 2, dimensionStyle);
            dim_karp.UserText = karp + "°";
            dxf.AddEntity(dim_karp);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
